/*
* $Id: DrawControl.cpp 16 2010-01-14 23:28:45Z volok-aleksej@yandex.ru $
*
* Copyright 2009 by Volokitin Alexey
* All rights reserved
*
*/
#include "Common/include.h"
#include "DrawControl.h"
#include "KeyProcess.h"

CDrawControl::CDrawControl(const std::tstring& strName)
: m_strValue(strName), m_rect(0, 0, 0, 0), m_bActive(false){}
CDrawControl::~CDrawControl(){
	for(std::vector<CKeyProcess*>::iterator it = m_aKeyProcess.begin(); it != m_aKeyProcess.end(); it++)
		delete *it;
}

void CDrawControl::SetActive(bool bActive){
	m_bActive = bActive;
}

void CDrawControl::SetPos(CPoint pos){
	m_rect.MoveToXY(pos);
}
void CDrawControl::SetCx(int cx){
	m_rect.right = m_rect.left + cx;
	Resize();
}
void CDrawControl::SetCy(int cy){
	m_rect.bottom = m_rect.top + cy;
}
int CDrawControl::GetSizeY(){
	return m_rect.Size().cy;
}

void CDrawControl::Paint(CDC* dc){
	if(m_bActive)
		PaintActive(dc);
	else
		PaintNonActive(dc);
}

std::tstring CDrawControl::GetValue(){
	return m_strValue;
}

bool CDrawControl::ProcessKey(unsigned int nChar, byte stateSysKey){
	for(std::vector<CKeyProcess*>::iterator it = m_aKeyProcess.begin(); it != m_aKeyProcess.end(); it++){
		if((*it)->IsProcess(nChar, stateSysKey))
			return (*it)->Process();
	}
	return false;
}

bool CDrawControl::ProcessMouse(unsigned int nChar, CPoint pos, int param){return false;}